package cn.xiangxiang.service.impl;

import cn.xiangxiang.mapper.goods.ParaMapper;
import cn.xiangxiang.pojo.goods.Para;
import cn.xiangxiang.service.goods.ParaService;
import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Map;

@Service(interfaceClass = ParaService.class)
public class ParaServiceImpl extends ServiceImpl<ParaMapper, Para> implements ParaService {

    @Override
    public Page<Para> findConditionPage(Integer startpage, Integer pagesize, Map<String,Object> map) {

        Page<Para> page = new Page<>(startpage, pagesize);
        Page<Para> paraPage = page(page, getCondition(map));
        return paraPage;
    }

    private QueryWrapper<Para> getCondition(Map<String,Object> map){
        QueryWrapper<Para> wrapper = new QueryWrapper<>();
        if(map!=null){
            if(map.get("name")!=null){
                wrapper.like("name",map.get("name"));
            }
            if(map.get("templateId")!=null){
                wrapper.eq("template_id",map.get("templateId"));
            }
        }
        return wrapper;
    }
}
